home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / gpt32src.zip / HPGL.TRM < prev    next >
Text File  |  1992-03-25  |  5KB  |  230 lines

  1. /*
  2.  * $Id: hpgl.trm,v 3.26 92/03/24 22:34:56 woo Exp Locker: woo $
  3.  */
  4.  
  5. /* GNUPLOT - hpgl.trm */
  6. /*
  7.  * Copyright (C) 1990, 1991, 1992   
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted, 
  11.  * provided that the above copyright notice appear in all copies and 
  12.  * that both that copyright notice and this permission notice appear 
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed 
  17.  * as patches to released version.
  18.  *  
  19.  * This software  is provided "as is" without express or implied warranty.
  20.  * 
  21.  * This file is included by ../term.c.
  22.  *
  23.  * This terminal driver supports:
  24.  *  hpgl, hp7580b, HP Laserjet III
  25.  *
  26.  * AUTHORS
  27.  *  Colin Kelley, Thomas Williams, Russell Lang
  28.  * 
  29.  * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
  30.  * 
  31.  */
  32.  
  33. #define HPGL_XMAX 15200
  34. #define HPGL_YMAX 10000
  35.  
  36. #define PCL_XMAX 10000
  37. #define PCL_YMAX  7500
  38.  
  39. #define HPGL_XLAST (HPGL_XMAX - 1)
  40. #define HPGL_YLAST (HPGL_XMAX - 1)
  41.  
  42. /* HPGL_VCHAR, HPGL_HCHAR  are not used */
  43. #define HPGL_VCHAR    (HPGL_YMAX/100*32/10) /* 3.2% */
  44. #define HPGL_HCHAR    (HPGL_XMAX/100*12/10) /* 1.2% */
  45. #define HPGL_VTIC    (HPGL_YMAX/70)        
  46. #define HPGL_HTIC    (HPGL_YMAX/70)        
  47.  
  48. #define PCL_VCHAR    (PCL_YMAX/100*32/10) /* 3.2% */
  49. #define PCL_HCHAR    (PCL_XMAX/100*12/10) /* 1.2% */
  50. #define PCL_VTIC    (PCL_YMAX/70)        
  51. #define PCL_HTIC    (PCL_YMAX/70)        
  52.  
  53. int HPGL_ang = 0;
  54.  
  55. HPGL_init()
  56. {
  57.     fputs("\033.Y\n",outfile);
  58. /*           1
  59.     1. enable eavesdropping
  60. */
  61. }
  62.  
  63. PCL_PORT_init()
  64. {
  65.       fputs("\033E\033&l1X\033&l0O\033&2A\033%0B;PW0.15\n",outfile);
  66. /*           1      2       3       4     5     6
  67.     1. reset the printer
  68.     2. one copy
  69.     3. portrait orientation
  70.     4. use letter paper
  71.     5. enter HP-GL/2 with old pen position
  72.     6. Pen Width
  73. */
  74. }
  75.  
  76. PCL_LAND_init()
  77. {
  78.     fputs("\033E\033&l1X\033&l1O\033%0B;PW0.15\n",outfile);
  79. /*
  80.                  1      2       3       4     5
  81.     1. reset the printer
  82.     2. one copy
  83.     3. landscape orientation
  84.     4. enter HP-GL/2 with old pen position
  85.     5. Pen Width
  86. */
  87. }
  88.  
  89.  
  90. PCL_graphics()
  91. {
  92.     fprintf(outfile,
  93.     "\033%0B\nIN;\nSC0,%d,0,%d;\nSR%f,%f;\n",
  94.         PCL_XMAX,PCL_YMAX,
  95.         ((double)(PCL_HCHAR)*200/3/PCL_XMAX),
  96.         ((double)(PCL_VCHAR)*100/2/PCL_YMAX) );
  97. /*     0         1    2             3 
  98.     0. enter HPGL/2 mode
  99.     1. reset to power-up defaults
  100.     2. set SCaling
  101.     3. set character size
  102. */
  103.     HPGL_ang = 0;
  104. }
  105.  
  106. HPGL_graphics()
  107. {
  108.     fprintf(outfile,
  109.     "IN;\nSC0,%d,0,%d;\nSR%f,%f;\n",
  110.         HPGL_XMAX,HPGL_YMAX,
  111.         ((double)(HPGL_HCHAR)*200/3/HPGL_XMAX),
  112.         ((double)(HPGL_VCHAR)*100/2/HPGL_YMAX) );
  113. /*     1    2             3 
  114.     1. reset to power-up defaults
  115.     2. set SCaling
  116.     3. set character size
  117. */
  118.     HPGL_ang = 0;
  119. }
  120.  
  121.  
  122. PCL_text()
  123. {
  124.     fputs("PU;\nSP0;\n\033.Z\0",outfile);
  125. /*           1    2     3
  126.     1. pen up
  127.     2. park pen
  128.     3. disable eavesdropping
  129. */
  130.     fputs("\n\033%1A\n\033&l0H\0",outfile);
  131. /*               1    2      3
  132.     1. enter PCL
  133.     2. eject page
  134.     3. reset printer
  135. */
  136. }
  137.  
  138. HPGL_text()
  139. {
  140.     fputs("PU;\nSP0;\n\033.Z\0",outfile);
  141. /*           1    2     3
  142.     1. pen up
  143.     2. park pen
  144.     3. disable eavesdropping
  145. */
  146. }
  147.  
  148.  
  149. HPGL_linetype(linetype)
  150. int linetype;
  151. {
  152. /* allow for 6 pens */
  153.     fprintf(outfile,"PU;\nSP%d;\n",(linetype+2)%6+1); 
  154. }
  155.  
  156.  
  157. HP75_linetype(linetype)
  158. int linetype;
  159. {
  160. /* allow for 4 pens */
  161.     fprintf(outfile,"PU;\nSP%d;\n",(linetype+2)%4+1); 
  162. }
  163.  
  164.  
  165. /* some early HPGL plotters (e.g. HP7220C) require the
  166.  * Pen Up/Down and Pen (move) Absolute commands to be separate
  167.  */
  168. HPGL_move(x,y)
  169. int x,y;
  170. {
  171.     fprintf(outfile,"PU;PA%d,%d;\n",x,y);
  172. }
  173.  
  174.  
  175. HPGL_vector(x,y)
  176. int x,y;
  177. {
  178.     fprintf(outfile,"PD;PA%d,%d;\n",x,y);
  179. }
  180.  
  181.  
  182. HPGL_put_text(x,y,str)
  183. int x, y;
  184. char *str;
  185. {
  186.     if (HPGL_ang == 1)
  187.         HPGL_move(x + HPGL_VCHAR/4,y);
  188.     else
  189.         HPGL_move(x,y - HPGL_VCHAR/4);
  190.     fprintf(outfile,"LB%s\003\n",str);
  191. }
  192.  
  193. PCL_put_text(x,y,str)
  194. int x, y;
  195. char *str;
  196. {
  197.         if (HPGL_ang == 1)
  198.                 HPGL_move(x + PCL_VCHAR/4,y);
  199.         else
  200.                 HPGL_move(x,y - PCL_VCHAR/4);
  201.         fprintf(outfile,"LB%s\003\n",str);
  202. }
  203.  
  204.  
  205. int HPGL_text_angle(ang)
  206. int ang;
  207. {
  208.     HPGL_ang = ang;
  209.     if (ang == 1)
  210.         /* vertical */
  211.         fprintf(outfile,"DI0,1;\n");
  212.     else
  213.         /* horizontal */
  214.         fprintf(outfile,"DI1,0;\n");
  215.     return TRUE;
  216. }
  217.  
  218. HPGL_reset()
  219. {
  220.        fprintf(outfile,"PG;\n");
  221.        /*  This HPGL command is ignored in HPGL/2 */
  222. }
  223.  
  224.  
  225. PCL_reset()
  226. {
  227.     fputs("\033%0A\033&l0H\033E\n",outfile);
  228. /*         PCL mode   eject reset  */
  229. }
  230.